package com.tian.controller;

import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.tian.dto.WxPrePayReqDto;
import com.tian.service.PayService;
import com.tian.util.CommonResult;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author tianwc  公众号：java后端技术全栈、面试专栏
 * @version 1.0.0
 * @date 2023年05月12日 15:57
 * 博客地址：<a href="http://woaijava.cc/">博客地址</a>
 * <p>
 * 支付
 */
@RestController
@RequestMapping(value = "/wx/pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class PayController {

    @Resource
    private PayService payService;

    @PostMapping("/prePay")
    public CommonResult<WxPayMpOrderResult> prePay(@RequestBody WxPrePayReqDto wxPrePayReqDto, HttpServletRequest request) {
        return payService.prePay(wxPrePayReqDto, request);
    }

    @PostMapping("/payNotify")
    public String payNotify(HttpServletRequest request, HttpServletResponse response) {
        return payService.payNotify(request, response);
    }
}
